<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class InfoManage extends CI_Controller {
	
	public function index(){
		$this->cismarty->assign('baseUrl',$this->config->item('base_url'));
		$this->load->model('Info');
		$newList=$this->Info->getNewList();
		$this->cismarty->assign('newList',$newList);
		$this->cismarty->display('info/main.tpl');
	}

	public function create(){
		$this->load->model('Info');
		$arr=array('title'=>$_POST['title'],'content'=>$_POST['content']);
		$this->Info->createNew($arr);
		self::index();
	}
	
	public function createInit(){
		$this->cismarty->assign('baseUrl',$this->config->item('base_url')); 
		$this->cismarty->display('info/insertNew.tpl');
	}
	
	public function delete(){
		$this->load->model('Info');
		$id=$_GET['id'];
		$this->Info->deleteNewInfoById($id);
		self::index();
	}
	
	public function update(){
			$this->load->model('Info');
			$arr=array('title'=>$_POST['title'],'content'=>$_POST['content']);
			$id=$_POST['id'];
			$this->Info->updateNewInfo($id,$arr);
			self::index();
	}
	
	public function updateInit(){
			$this->load->model('Info');
			$updateInfo=$this->Info->getNewInfoById($_GET['id']);
			$this->cismarty->assign('updateInfo',$updateInfo);
			
			$this->cismarty->assign('baseUrl',$this->config->item('base_url')); 
			$this->cismarty->display('info/updateNew.tpl');
	}
}